#ifndef _SESSION_MGR_UTILS_H
#define _SESSION_MGR_UTILS_H

#include <stdint.h>

#include <map>

namespace session_mgr
{
    template <typename Key, typename Value, typename Compare, typename Alloc>
    class MapInserter
    {
    public:
        MapInserter(std::map<Key, Value, Compare, Alloc> &dest):
        dest(dest)
        {}
        
        MapInserter<Key, Value, Compare, Alloc>& operator () (Key const& key, Value const& value)
        {
            dest.insert(std::make_pair(key, value));
            return *this;
        }
        
    private:
        std::map<Key, Value, Compare, Alloc> &dest;
    };
    
    template <typename Key, typename Value, typename Compare, typename Alloc>
    MapInserter<Key, Value, Compare, Alloc> insertInto(std::map<Key, Value, Compare, Alloc> &dest)
    {
        return MapInserter<Key, Value, Compare, Alloc>(dest);
    }
    
    inline uint32_t addr(uint32_t a, uint32_t b, uint32_t c, uint32_t d)
    {
        return (a << 24) | (b << 16) | (c << 8) | d;
    }
}

#endif
